/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ipfms.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author fikri
 */
@Entity
@Table(name = "building_img")

public class BuildingImg implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_img")
    private Integer idImg;
    
    @ManyToOne (fetch = FetchType.LAZY)
    @JoinColumn (name = "id_building")
    private Building building;
//    @EmbeddedId
//    protected BuildingImgPK buildingImgPK;
    @Basic(optional = false)
    @Column(name = "img_name")
    private String imgName;
    @Basic(optional = false)
    @Column(name = "img_path")
    private String imgPath;
    
    @Basic(optional = false)
    @Column(name = "format")
    private String format;
    
//    @JoinColumn(name = "id_building", referencedColumnName = "id_building", insertable = false, updatable = false)
//    @ManyToOne(optional = false)
//    private Building building;
    
    @Embedded
    private InfoAudit infoAufit;

    public BuildingImg() {
    }

    public Integer getIdImg() {
        return idImg;
    }

    public void setIdImg(Integer idImg) {
        this.idImg = idImg;
    }

//    public BuildingImg(BuildingImgPK buildingImgPK) {
//        this.buildingImgPK = buildingImgPK;
//    }
//
//    public BuildingImg(BuildingImgPK buildingImgPK, String imgName, String imgPath) {
//        this.buildingImgPK = buildingImgPK;
//        this.imgName = imgName;
//        this.imgPath = imgPath;        
//    }
//
//    public BuildingImg(int idImg, int idBuilding) {
//        this.buildingImgPK = new BuildingImgPK(idImg, idBuilding);
//    }
//
//    public BuildingImgPK getBuildingImgPK() {
//        return buildingImgPK;
//    }
//
//    public void setBuildingImgPK(BuildingImgPK buildingImgPK) {
//        this.buildingImgPK = buildingImgPK;
//    }

    public String getImgName() {
        return imgName;
    }

    public void setImgName(String imgName) {
        this.imgName = imgName;
    }

    public String getImgPath() {
        return imgPath;
    }

    public void setImgPath(String imgPath) {
        this.imgPath = imgPath;
    }

    public InfoAudit getInfoAufit() {
        return infoAufit;
    }

    public void setInfoAufit(InfoAudit infoAufit) {
        this.infoAufit = infoAufit;
    }    

    public Building getBuilding() {
        return building;
    }

    public void setBuilding(Building building) {
        this.building = building;
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }

     @Override
    public int hashCode() {
        int hash = 0;
        hash += (idImg != null ? idImg.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Building)) {
            return false;
        }
        BuildingImg other = (BuildingImg) object;
        if ((this.idImg == null && other.idImg != null) || (this.idImg != null && !this.idImg.equals(other.idImg))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ipfms.model.BuildingImg[ buildingImgPK=" + idImg + " ]";
    }
    
}
